package com.uroad.jilinpda.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;


import com.flyco.tablayout.SlidingTabLayout;
import com.uroad.jilinpda.R;
import com.uroad.jilinpda.adapter.FragmentViewPagerAdapter;
import com.uroad.jilinpda.common.BaseActivity;
import com.uroad.jilinpda.fragment.ActivatedFragment;
import com.uroad.jilinpda.fragment.IssueFailureFragment;
import com.uroad.jilinpda.fragment.IssueFragment;
import com.uroad.jilinpda.fragment.TobeActivatedFragment;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ReleaserecordsActivity extends BaseActivity {

    @BindView(R.id.tablayout)
    SlidingTabLayout tablayout;
    @BindView(R.id.vp_order_query)
    ViewPager vp_order_query;
    private String[] titles= {"发行中", "发行失败","待激活", "已激活"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setBaseContentLayout(R.layout.activity_releasere_cords);
        setTitle("我的订单");
        ButterKnife.bind(this);
        initView();
    }

    private void initView(){
        ArrayList<Fragment> fragments = new ArrayList<>();
        IssueFragment issueFragment = new IssueFragment();
        fragments.add(issueFragment);
        IssueFailureFragment issuefailureFragment = new IssueFailureFragment();
        fragments.add(issuefailureFragment);
        TobeActivatedFragment bandactivationFragment = new TobeActivatedFragment();
        fragments.add(bandactivationFragment);
        ActivatedFragment activatedFragment = new ActivatedFragment();
        fragments.add(activatedFragment);
        /*AuditedFragment auditedFragment = new AuditedFragment();
        fragments.add(auditedFragment);
        CancelledFragment cancelledFragment = new CancelledFragment();
        fragments.add(cancelledFragment);*/

        FragmentViewPagerAdapter pagerAdapter = new FragmentViewPagerAdapter(this.getSupportFragmentManager(), vp_order_query,fragments);
        pagerAdapter.setOnExtraPageChangeListener(new FragmentViewPagerAdapter.OnExtraPageChangeListener(){
            @Override
            public void onExtraPageSelected(int i) {
                switch (i){
                    case 0:
                        issueFragment.setUserVisibleHint(true);
                        break;
                    case 1:
                        issuefailureFragment.setUserVisibleHint(true);
                        break;
                    case 2:
                        bandactivationFragment.setUserVisibleHint(true);
                        break;
                    case 3:
                        activatedFragment.setUserVisibleHint(true);
                        break;
              /*      case 4:
                        auditedFragment.setUserVisibleHint(true);
                        break;
                    case 5:
                        cancelledFragment.setUserVisibleHint(true);
                        break;*/
                }


            }
        });

        vp_order_query.setAdapter(pagerAdapter);
        pagerAdapter.setPageTitle(titles);
        tablayout.setViewPager(vp_order_query);

    }

}
